<template>
  <el-card>
    <el-form :model="ordersData" size="mini" class="dialog">
      <el-form-item label="订单号">
        <el-input v-model="ordersData.orderNo" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="手机号">
        <el-input v-model="ordersData.phone" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="收货人">
        <el-input v-model="ordersData.consignee" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="配送地址">
        <el-input
          v-model="ordersData.deliverAddress"
          autocomplete="off"
        ></el-input>
      </el-form-item>
      <el-form-item label="用户备注">
        <el-input v-model="ordersData.remarks" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="订单金额">
        <el-input
          v-model="ordersData.orderAmount"
          autocomplete="off"
        ></el-input>
      </el-form-item>
      <el-form-item label="订单状态">
        <el-input v-model="ordersData.orderState" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="下单时间">
        <el-date-picker
          v-model="ordersData.orderTime"
          type="date"
          placeholder="选择日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="送达时间">
        <el-date-picker
          v-model="ordersData.deliveryTime"
          type="date"
          placeholder="选择日期"
        >
        </el-date-picker>
      </el-form-item>
    </el-form>
    <el-button @click="$router.push('/orders/list')">取 消</el-button>
    <el-button type="primary" @click="alterOrders">确 定</el-button>
  </el-card>
</template>

<script>
import { orderEdit, detail } from '@/api/orders.js'
import { error } from '@/utils/hint.js'
export default {
  data() {
    return {
      ordersData: {}
    }
  },
  created() {
    this.editList()
  },
  mounted() {},

  methods: {
    /* 修改列表 */
    async alterOrders() {
      const { code, msg } = await orderEdit(this.ordersData)
      if (code === 0) {
        setTimeout(() => this.$router.push('/orders/list'), 1500)
      } else {
        error(msg)
      }
    },
    async editList() {
      const { data } = await detail({ id: this.$route.query.id })
      this.ordersData = data
    }
  }
}
</script>

<style lang="less" scoped>
.el-form {
  width: 50%;
  display: flex;
  flex-wrap: wrap;
  /deep/.el-form-item {
    margin-right: 10px;
  }
  /deep/.el-date-picker {
    width: 100%;
  }
}
</style>
